require 'rubygems'
gem 'soap4r'
require 'soap/wsdlDriver'
require 'soap/header/simplehandler'
require 'defaultDriver.rb'
require 'authStub.rb'

#Async create options
#options = CreateOptions.new(nil,nil,nil,nil,nil,nil,nil,nil,'Asynchronous')
options = nil

subs = [['EmailAddress','FirstName','PhoneNumber'],['Sheldon_Schumacher_35464@bh.exacttarget.com','Sheldon','13174233928'],['Quentin_Mcclendon_21075@bh.exacttarget.com','Quentin','13174233928'],['Faith_Hines_57278@bh.exacttarget.com','Faith','13174233928'],['Edd_Dean_42632@bh.exacttarget.com','Edd','13174233928']]

ttlRows = subs.length
ttlRowsToSend = 2
procTo = ttlRowsToSend
ttlToSend = ttlRows > ttlRowsToSend ? ttlRowsToSend : ttlRows

hdr = String.new
rows = Array.new

subs.each_with_index do |line, i|

  columns = Array.new

  if i == 0 then
    hdr = line
  else
    line.each_with_index do |items, c|
      columns.push(APIProperty.new(hdr[c].chomp,items.chomp))
    end
  end

  if i == procTo or i == (ttlRows - 1) then
    rows.push(DataExtensionObject.new(nil,nil,nil,nil,nil,nil,nil,'APITestSendDe0',nil,nil,nil,[*columns]))
    resp = $driver.create(CreateRequest.new(options,[*rows]))
    rows.clear
    procTo = i != ttlRows ? procTo + ttlRowsToSend : nil
  else
    rows.push(DataExtensionObject.new(nil,nil,nil,nil,nil,nil,nil,'APITestSendDe0',nil,nil,nil,[*columns]))
  end
end